package org.example;

import org.example.protobuf.Example.Person;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;

public class ProtobufDataConsumer {


    public static void main(String[] args) {
        try (FileInputStream fis = new FileInputStream("persons_data.bin")) {
            Person person;
            int cnt=0;
            while ((person = Person.parseDelimitedFrom((InputStream) fis)) != null) {
                // 处理每条记录
                System.out.println("==== "+ cnt++);
                System.out.println(person);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }

    }
}
